package com.tdkj.service.shop.impl;

import org.springframework.stereotype.Component;

import com.tdkj.model.shop.BeanShop;
import com.tdkj.model.shop.BeanShopRecommendationType;
import com.tdkj.model.shop.BeanShopRecommendationUseInfo;
import com.tdkj.service.BaseService;
import com.tdkj.service.shop.IBeanShopRecommendationUseInfoService;

@Component
public class BeanShopRecommendationUseInfoServiceImpl extends BaseService
		implements IBeanShopRecommendationUseInfoService {

	@Override
	public void create(Long shopId, Long typeId) {
		BeanShop shop = this.getBaseDao().findById(shopId, BeanShop.class);
		BeanShopRecommendationType type = this.getBaseDao().findById(typeId, BeanShopRecommendationType.class);
		if(shop.getShopRecommendationUseInfo() == null){
			BeanShopRecommendationUseInfo useInfo = new BeanShopRecommendationUseInfo();
			useInfo.setType(type);
			useInfo.setShop(shop);
			useInfo.setLimitTime(1000L*24*60*60);
			useInfo.setState(1);
			this.getBaseDao().save(useInfo);
			
			shop.setShopRecommendationUseInfo(useInfo);
		}else{
			shop.getShopRecommendationUseInfo().setLimitTime(1000L*24*60*60);
			shop.getShopRecommendationUseInfo().setState(1);
		}
	}

}
